02 / 06

What is the difference between inline and block elements?

Difference Between Inline and Block Elements in HTML

In HTML, elements are categorized as either inline or block, which affects how they are rendered on the page and how they interact with surrounding content.

Key Differences
  1. 1

    Block Elements:

  2. 2
    • Start on a new line and take up the full width available by default.
  3. 3
    • Can contain other block or inline elements.
  4. 4
    • Examples: <div>, <p>, <h1><h6>, <ul>, <ol>.
  5. 5

    Inline Elements:

  6. 6
    • Do not start on a new line and only take up as much width as necessary.
  7. 7
    • Can only contain text or other inline elements.
  8. 8
    • Examples: <span>, <a>, <strong>, <em>.
Example Usage

In short: Block elements structure the layout by occupying full width and stacking vertically, while inline elements flow within text and only occupy the space their content needs.